<template>
	<view v-if="meetId > 0">
		<view class="info" v-show="current === 0"><info-detail ref="page_view0" :meetId="meetId" @getShare="customShareParams"></info-detail></view>
		<view v-show="current === 1"><schedule-list ref="page_view1" :current="current" :procedure="procedure"></schedule-list></view>
		<view v-show="current === 2"><guest-list ref="page_view2" :current="current" :type="1" :meetId="meetId"></guest-list></view>
		<view v-show="current === 3"><guest-list ref="page_view3" :current="current" :type="2" :meetId="meetId"></guest-list></view>
		<u-tabbar v-model="current" :list="tabList" :active-color="vuex_config.themeColor1" @change="onChange"></u-tabbar>
	</view>
</template>

<script>
import infoDetail from './pageComponents/infoDetail.vue';
import scheduleList from './pageComponents/scheduleList.vue';
import guestList from './pageComponents/guestList.vue';
import { pageShare } from '@/mixins/pageShare.js';
export default {
	mixins: [pageShare],
	components: {
		'info-detail': infoDetail,
		'schedule-list': scheduleList,
		'guest-list': guestList
	},
	data() {
		return {
			meetId: null,
			init:false,
			current: 0,
			tabList: [
				{
					text: '主页',
					pageTitle: '首页',
					iconPath: 'e63d',
					selectedIconPath: 'e63c'
				},
				{
					text: '日程',
					pageTitle: '活动日程',
					iconPath: 'e69d',
					selectedIconPath: 'e69d'
				},
				{
					text: '嘉宾',
					pageTitle: '嘉宾',
					iconPath: 'e66e',
					selectedIconPath: 'e66e'
				},
				{
					text: '展商',
					pageTitle: '展商',
					iconPath: 'e8e7',
					selectedIconPath: 'e8e7'
				}
			],
			procedure: ''
		};
	},
	onLoad(options) {
		if (options && options.id) {
			this.meetId = Number(options.id || 1);
		}
		uni.setNavigationBarTitle({ title: this.tabList[this.current].pageTitle });
	},
	onShow () {
		if(this.init){
			this.$refs.page_view0.init()
		}else{
			this.init = true
		}
	},
	// 微信小程序分享(好友)
	onShareAppMessage: function() {
		return this.getShareAppMessage();
	},
	onPullDownRefresh: function() {
		try {
			let str = 'page_view' + this.current;
			if (this.$refs[str].$onPullDownRefresh) {
				this.$refs[str].$onPullDownRefresh();
			}
		} catch (e) {}
		setTimeout(() => {
			uni.stopPullDownRefresh();
		}, 700);
	},
	onReachBottom: function() {
		try {
			let str = 'page_view' + this.current;
			if (this.$refs[str].$onReachBottom) {
				this.$refs[str].$onReachBottom();
			}
		} catch (e) {}
	},
	methods: {
		// 切换会议id
		changeMeet(id) {
			this.init = false
			this.meetId = null;
			this.current = 0;
			this.$nextTick(() => {
				this.meetId = id;
			});
		},
		customShareParams(obj) {
			this.procedure = obj.procedure;
			if (!this.shareParams.title) {
				let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
				let curRoute = routes[routes.length - 1].route; //获取当前页面路由
				let curParam = routes[routes.length - 1].options; //获取路由参数
				this.shareParams = {
					title: obj.name,
					path: curRoute,
					query: { id: this.meetId },
					imgUrl: obj.logo || ''
				};
				this.onShareByH5();
			}
		},
		onChange(index) {
			uni.setNavigationBarTitle({ title: this.tabList[index].pageTitle });
			this.$nextTick(() => {
				let str = 'page_view' + index;
				if (this.$refs[str].init) {
					this.$refs[str].init();
				}
			});
		}
	}
};
</script>
<style lang="scss">
page {
	background-color: #f5f5f5;
}
</style>
<style scoped lang="scss"></style>
